buildFlag=$1
#zipFolder=$2

basePath="/Users/irre/Desktop/mateurp"
projectPath=${basePath}/mateurp

substring=$(date "+%Y-%m-%d_%H-%M-%S")

artZipFileName=${buildFlag}_${substring}.zip

IPV4=$(/sbin/ifconfig en0 | grep 'inet ' | awk '{print $2}')

source_zipPath=/Volumes/USB/Web/$artZipFileName

preserveStr=${buildFlag}_$(date "+%Y-%m-%d")
files=$(find /Volumes/USB/Web -type f -name "${buildFlag}*")

for file in $files
do
    if [[ "$(basename $file)" != "${preserveStr}*" ]];then
        echo "remove $file"
        rm -f $file
    fi
done

#dirs=$(find ${zipFolder} -type d -maxdepth 1)

cd $projectPath
zip -r $source_zipPath ArtPackages

json="{\"text\":{\"content\":\"${buildFlag},角色资源打包完成,下载地址：http://${IPV4}/${artZipFileName}\"},\"msgtype\":\"text\"}"
echo $json
curl -H "Content-Type: application/json" -X POST -d "$json" https://oapi.dingtalk.com/robot/send?access_token=1dd9ef311951334ba9e001f194f78c99ee8b74fff2c56b5f899c1727302f60b8